<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/bootbox.min.js',2); ?>
<div class="page-header">
							<h3 class="red">已添加的学生报名</h3>
</div>
<div class="row">
  <div class="col-xs-12">
		<div class="row">
						<div class="widget-box">
											<div class="widget-header widget-header-small">
												<h5 class="lighter"></h5>
											</div>

											<div class="widget-body">
												<div class="widget-main">

											<div class="table-responsive">
											<table id="sample-table-1" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
														
														<th>活动名称</th>
														
														<th class=" ">活动内容</th>
														
														<th class=" ">活动要求</th>
														<th class=" ">状态</th>
														<th class=" ">已参加人数</th>
														<th class=" ">规定参加人数</th>
														
														

														<th>
															<i class="icon-time bigger-110  "></i>
															添加时间
														</th>
														
														<th>操作</th>
													</tr>
												</thead>

												<tbody>
												<?php
												  foreach($acs as $a){
													  $isclosed = '<span class="label label-info arrowed">已开启</span>';
													  if($a->isclosed === '1'){
														  $isclosed = '<span class="label label-warning arrowed">已关闭</span>';
													  }
													 echo '
													<tr id = "'.$a->activityId.'">
														<td>
															<a href="#">'.$a->name.'</a>
														</td>
														
														<td class=" ">
														<span display-content-id="'.$a->activityId.'" style="display:none;">'.$a->content.'</span>
															<button class="btn btn-sm btn-info" content-id="'.$a->activityId.'">
																详情
															</button>
														</td>
														
														<td>
														 <span display-requirement-id="'.$a->activityId.'" style="display:none;">'.$a->requirement.'</span>
														  <button class="btn btn-sm btn-warning" requirement-id="'.$a->activityId.'" >
														    要求
														  </button>
														</td>
														<td>'.$isclosed.'</td>
														<td>'.$a->attendnum.'</td>
														<td>'.$a->stunum.'</td>
														
														
														<td>'.$a->addtime.'</td>
														

														
														<td>
															<div >
												             
															    <a>
																<button class="btn btn-xs btn-danger" data-rel="tooltip" data-original-title = "删除" delete-ac = "'.$a->activityId.'">
																	<i class="icon-trash bigger-120"></i>
																</button>
																</a>
																<a href="'.Yii::app()->createUrl('activity/activityreport',array('id'=>$a->activityId)).'" target="_blank"> 
																	<button class="btn btn-xs btn-warning" data-rel="tooltip" data-original-title = "报表">
																		<i class="icon-list bigger-120"></i>
																	</button>
																</a>
																<a>
																 <button class="btn btn-xs btn-info" data-rel="tooltip" data-original-title = "停止活动" stop-ac = "'.$a->activityId.'">
																	<i class="icon-remove bigger-120"></i>
																 </button>
																</a>
																<a>
																 <button class="btn btn-xs btn-success" data-rel="tooltip" data-original-title = "开启活动" start-ac = "'.$a->activityId.'">
																	<i class="icon-ok bigger-120"></i>
																 </button>
																</a>
															</div>

														</td>
													</tr>';
												  }
                                                   ?>
												</tbody>
											</table>
										</div><!-- /.table-responsive -->
						</div>
					</div>
				
				</div>
			</div>
		</div>
	</div>

<script type="text/javascript">
  jQuery(function($){
	  
   	 $('[delete-ac]').on('click',function(){
		var id = $(this).attr('delete-ac');
		bootbox.confirm('删除这个活动，这个活动下学生添加的所有记录，都会被删除！',function(result){
			if(result){
			$.post("<?php echo Yii::app()->createUrl('activity/delete') ?>",{'id':id},function(data){
				data = $.parseJSON(data);
				bootbox.alert(data['msg'],function(){
					if(data['code'] == '200'){
						$('#'+id).fadeToggle('800','linear',function(){
							$(this).remove();
							
						});
						
					}
					
				});
				
			});
		  }
		});
		
		 
	 });

	$('[requirement-id]').on("click",function(){
			var id = $(this).attr('requirement-id');
			bootbox.alert($("[display-requirement-id = "+id+"]").html(),function(){
								
			});

	   });
	   
	   $('[content-id]').on("click",function(){
			var id = $(this).attr('content-id');
			bootbox.alert($("[display-content-id = "+id+"]").html(),function(){
				
			});
	   }); 
	 $('[stop-ac]').on("click",function(){
		var id = $(this).attr('stop-ac');
        bootbox.confirm("关闭这个活动之后，学生将无法参加这个活动！！",function(result){
			if(result){
				$.post("<?php echo Yii::app()->createUrl('activity/closeactivity') ?>",{'id':id},function(data){
				data = $.parseJSON(data);
				bootbox.alert(data['msg'],function(){
					if(data['code'] == '200'){
						  window.location.reload();
						
					}
					
				});
				
			});
			}
		});
	 });
	 
     $('[start-ac]').on("click",function(){
		var id = $(this).attr('start-ac');
        bootbox.confirm("你确定要开启这个活动吗？",function(result){
			if(result){
				
				$.post("<?php echo Yii::app()->createUrl('activity/startactivity') ?>",{'id':id},function(data){
					data = $.parseJSON(data);
					bootbox.alert(data['msg'],function(){
						if(data['code'] == '200'){
							  window.location.reload();
							
						}
						
					});
				
			});
			}
		});
	 });    
	
  });
</script>